//
//  CellForGuoWai.m
//  SeeTheWorld
//
//  Created by dllo on 16/1/27.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "CellForGuoWai.h"
#import "PCH.pch"
#import "ModelForGuoWai.h"
#import <UIImageView+WebCache.h>


@interface CellForGuoWai ()

@property (nonatomic, retain)UIImageView *imageViewOfBack;
@property (nonatomic, retain)UILabel *labelOfName;
@property (nonatomic, retain)UILabel *labelOfEnglish;
@property (nonatomic, retain)UILabel *labelOfCount;

@end

@implementation CellForGuoWai

- (void)dealloc {
    [_imageViewOfBack release];
    [_labelOfCount release];
    [_labelOfEnglish release];
    [_labelOfName release];
    [super dealloc];
}

- (instancetype)initWithFrame:(CGRect)frame {
    
    self = [super initWithFrame:frame];
    if (self) {
        
        [self createSubviews];
        
    }
    return self;
}

#pragma mark - 创建子视图
- (void)createSubviews {
    
    self.imageViewOfBack = [[UIImageView alloc] init];
    [self.contentView addSubview:self.imageViewOfBack];
    [_imageViewOfBack release];
    
    self.labelOfName = [[UILabel alloc] init];
    [self.contentView addSubview:self.labelOfName];
    [_labelOfName release];
    self.labelOfName.textColor = [UIColor whiteColor];
    self.labelOfName.font = [UIFont systemFontOfSize:22];
    
    self.labelOfEnglish = [[UILabel alloc] init];
    [self.contentView addSubview:self.labelOfEnglish];
    [_labelOfEnglish release];
    self.labelOfEnglish.textColor = [UIColor whiteColor];
    self.labelOfEnglish.font = [UIFont systemFontOfSize:17];
    
    self.labelOfCount = [[UILabel alloc] init];
    [self.contentView addSubview:self.labelOfCount];
    [_labelOfCount release];
    self.labelOfCount.textColor = [UIColor whiteColor];
    self.labelOfCount.textAlignment = NSTextAlignmentCenter;
    self.labelOfCount.font = [UIFont systemFontOfSize:14];
    
}

#pragma mark - 布局子视图
- (void)applyLayoutAttributes:(UICollectionViewLayoutAttributes *)layoutAttributes {
    
    self.imageViewOfBack.frame = self.contentView.frame;
    self.labelOfName.frame = CGRectMake(12, 8, scWIDTH, 20);
    self.labelOfEnglish.frame = CGRectMake(10, 30, scWIDTH, 20);
    
    self.labelOfCount.frame = CGRectMake(20, scHEIGHT - 30, scWIDTH - 40, 20);
    
}

#pragma mark - 赋值
- (void)passModel:(ModelForGuoWai *)model {

    [self.imageViewOfBack sd_setImageWithURL:[NSURL URLWithString:model.image_url] placeholderImage:[UIImage imageNamed:@"1f178a82b9014a90e9109296ad773912b31beeeb"]];
    
    self.labelOfName.text = model.name_zh_cn;
    
    self.labelOfEnglish.text = model.name_en;
    
    NSString *str = [NSString stringWithFormat:@"旅行地 %@", model.poi_count];
    
    self.labelOfCount.text = str;
    
}











@end
